package com.burstly.lib.component.networkcomponent;

import android.content.Context;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.drawable.ShapeDrawable;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnFocusChangeListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import com.burstly.lib.util.LoggerExt;
import com.burstly.lib.util.Utils;

public class FocusAwareLayout extends FrameLayout
  implements View.OnFocusChangeListener
{
  private static final int BORDER_ALPHA_LEVEL = 200;
  private static final LoggerExt LOG = LoggerExt.getInstance();
  private static final float STROKE_WIDTH = 5.0F;
  private static final String TAG = "FocusAwareLayout";
  private FrameLayout mBorder;
  private boolean mBorderEnabled = true;
  private View mChildView;
  private ShapeDrawable mFocusBorder;
  private View.OnFocusChangeListener mOriginalListener;

  public FocusAwareLayout(Context paramContext)
  {
    this(paramContext, null);
  }

  public FocusAwareLayout(Context paramContext, View paramView)
  {
    super(paramContext);
    if (paramView != null)
    {
      addView(paramView);
      this.mChildView = paramView;
    }
  }

  private void changeBorderState(boolean paramBoolean)
  {
    if (this.mBorder != null)
    {
      if (paramBoolean)
        addView(this.mBorder, new FrameLayout.LayoutParams(getWidth(), getHeight(), 17));
    }
    else
      return;
    removeView(this.mBorder);
  }

  public void addView(View paramView, int paramInt, ViewGroup.LayoutParams paramLayoutParams)
  {
    super.addView(paramView, paramInt, paramLayoutParams);
    this.mChildView = paramView;
    paramView.setFocusableInTouchMode(false);
    if (paramView.isFocusable())
    {
      this.mBorder = new FrameLayout(getContext());
      this.mOriginalListener = paramView.getOnFocusChangeListener();
      this.mFocusBorder = new ShapeDrawable();
      this.mFocusBorder.setAlpha(200);
      this.mFocusBorder.setPadding(3, 3, 3, 3);
      Paint localPaint = this.mFocusBorder.getPaint();
      localPaint.setColor(-16711936);
      localPaint.setStyle(Paint.Style.STROKE);
      localPaint.setStrokeWidth(5.0F);
      Utils.setBackgroundDrawable(this.mBorder, this.mFocusBorder);
      paramView.setOnFocusChangeListener(this);
    }
  }

  protected FrameLayout.LayoutParams generateDefaultLayoutParams()
  {
    return new FrameLayout.LayoutParams(-2, -2);
  }

  public void onFocusChange(View paramView, boolean paramBoolean)
  {
    if (this.mOriginalListener != null)
      this.mOriginalListener.onFocusChange(paramView, paramBoolean);
    if (this.mBorderEnabled)
      changeBorderState(paramBoolean);
  }

  public boolean onTouchEvent(MotionEvent paramMotionEvent)
  {
    try
    {
      boolean bool = super.onTouchEvent(paramMotionEvent);
      return bool;
    }
    catch (Exception localException)
    {
      LOG.logWarning("FocusAwareLayout", Log.getStackTraceString(localException), new Object[0]);
    }
    return true;
  }

  public void setBorderEnabled(boolean paramBoolean)
  {
    this.mBorderEnabled = paramBoolean;
    if (!paramBoolean)
      changeBorderState(false);
  }

  public void setTag(Object paramObject)
  {
    super.setTag(paramObject);
    if (this.mChildView != null)
      this.mChildView.setTag(paramObject);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.component.networkcomponent.FocusAwareLayout
 * JD-Core Version:    0.6.2
 */